package xyz.zhzby.cyzx.com.convert;

import io.swagger.annotations.ApiModel;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import xyz.zhzby.cyzx.com.dto.request.DiscussionAddRequest;
import xyz.zhzby.cyzx.com.dto.response.DiscussionResponse;
import xyz.zhzby.cyzx.com.entity.Discussion;

/**
 * @author zby
 * @date 2022/01/19
 */
@ApiModel("讨论相关转换器")
@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface DiscussionConvert {

    DiscussionConvert INSTANCE = Mappers.getMapper(DiscussionConvert.class);

    Discussion REQUEST_DISCUSSION(DiscussionAddRequest discussionAddRequest);

    @Mappings({
            @Mapping(target = "userNickName", source = "userNickname"),
            @Mapping(target = "toUserId", source = "replyToUserId"),
            @Mapping(target = "toUserNickName", source = "replyToUserNickname"),
            @Mapping(target = "publishDate", source = "createTime")
    })
    DiscussionResponse DISCUSSION_RESPONSE(Discussion discussion);

}
